Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/11066
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
파일을 합칠 때 각 파일의 크기의 합만큼 코스트가 발생합니다. 파일은 인접한 것 2개 끼리 합칠 수 있습니다.
여러개의 파일이 주어졌을 때 파일을 전부 합쳤을 때 드는 최소비용을 구하는 문제입니다.
🔍 풀이 방법
DP를 이용해서 풀었습니다.
3중 for문에서 dp를 활용하여 2개 묶음, 3개 묶음... 이런 식으로 묶음의 크기를 늘렸습니다.
그 속에서 어떤식으로 묶었을 때 최소비용인지를 dp 배열을 이용해서 갱신했습니다.
dp[i][j] = dp[i][k] + dp[k+1][j] 로 i번부터 j번 파일까지 합치는 비용을 계산했습니다.
⏳ 회고
그리디적인 방법으로 접근하려 했으나 인접한 2개 끼리만 합칠 수 있다는 조건으로 다른 방법을 생각하는 것이 쉽지 않았습니다.